import 'package:floating_draggable_widget/floating_draggable_widget.dart';
import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:gluz/app/utils/colors.dart';
import 'package:marquee/marquee.dart';

import '../../../../app_session.dart';
import '../controllers/home_controller.dart';
import 'package:gluz/app/common/extension/string_extension.dart';

class HomeView extends GetView<HomeController> {
  const HomeView({super.key});
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.color_F7F7F7,
      body: FloatingDraggableWidget(
        floatingWidget: Image.asset('assets/images/home/home_trans_icon.png'),
        autoAlignType: AlignmentType.onlyRight,
        autoAlign: true,
        disableBounceAnimation: true,
        floatingWidgetHeight: 60,
        floatingWidgetWidth: 80,
        dx: Get.size.width - 80,
        dy: 100,
        screenHeight: Get.size.height - Get.bottomBarHeight,
        mainScreenWidget: SingleChildScrollView(
          child: Stack(
            children: [
              Container(height: app.isLangRU() ? Get.height + 80 : Get.height,),
              Stack(
                children: [
                  Image.asset('assets/images/home/home_top_bg.png'),
                  Positioned(
                    bottom: 60,
                    left: 20,
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text('全球线上展会\n将您的产品卖向全球',
                          textAlign: TextAlign.start,
                          style: TextStyle(fontSize: 20,fontWeight: FontWeight.bold, color: Colors.white),
                        ),
                        Text('Пересекая горы и моря, встречая будущее',
                          textAlign: TextAlign.start,
                          style: TextStyle(fontSize: 10, color: Colors.white),),
                        const SizedBox(height: 10,),
                        Image.asset('assets/images/home/home_enter_live_btn.png', width: 100,),
                      ],
                    ),
                  ),
                ],
              ),
              Positioned(
                left: 10,
                top: 230,
                right: 10,
                child: Column(
                  spacing: 10,
                  children: [
                    Card(
                      color: Colors.white,
                      elevation: 0.1,
                      child: Padding(
                        padding: const EdgeInsets.all(10.0),
                        child: Column(
                          spacing: 10,
                          children: [
                            Container(
                              height: 35,
                              padding: const EdgeInsets.symmetric(horizontal: 10),
                              decoration: BoxDecoration(
                                color: AppColors.color_EBF8FF,
                                borderRadius: BorderRadius.circular(17),
                              ),
                              child: Row(children: [
                                Image.asset('assets/images/home/home_icon_bell.png', width: 20,),
                                Expanded(child: marQueenWidget()),
                              ],),
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceAround,
                              spacing: 8,
                              children: [
                                Expanded(child:
                                  InkWell(
                                    onTap: controller.onTapShop,
                                    child: Image.asset('assets/images/home/${"home_item_shop".localRuTail()}.png'),
                                  ),
                                ),
                                Expanded(child: Image.asset('assets/images/home/${"home_item_caigou".localRuTail()}.png')),
                              ],
                            ),
                            Stack(
                              children: [
                                Image.asset('assets/images/home/${"home_item_trans".localRuTail()}.png'),
                              ],
                            ),

                          ],
                        ),
                      ),
                    ),

                    Card(
                      color: AppColors.color_91D6FF,
                      elevation: 0.1,
                      child: Image.asset('assets/images/home/${"home_item_yshd".localRuTail()}.png'),
                    ),


                    Card(
                      color: Colors.white,
                      elevation: 0.1,
                      child: Padding(
                        padding: const EdgeInsets.all(10.0),
                        child: Row(
                          spacing: 8,
                          mainAxisAlignment: MainAxisAlignment.spaceAround,
                          children: [
                          Expanded(child: Image.asset('assets/images/home/${"home_item_db".localRuTail()}.png')),
                          Expanded(child: Column(
                            spacing: 8,
                            children: [
                              Image.asset('assets/images/home/${"home_item_ad".localRuTail()}.png'),
                              Image.asset('assets/images/home/${"home_item_bg".localRuTail()}.png'),
                            ],
                          ))
                        ],),
                      ),
                    ),
                  ],
                ),
              ),



            ],
          ),
        )
      ),
    );
  }

  Widget marQueenWidget() {
    return SizedBox(
      height: 30,
      child: Marquee(
        text: 'Some sample text that takes some space. text that takes some space.',
        style: TextStyle(fontWeight: FontWeight.normal, fontSize: 13),
        scrollAxis: Axis.horizontal,
        crossAxisAlignment: CrossAxisAlignment.center,
        blankSpace: 20.0,
        velocity: 100.0,
        pauseAfterRound: Duration(seconds: 1),
        startPadding: 10.0,
        accelerationDuration: Duration(seconds: 1),
        accelerationCurve: Curves.linear,
        decelerationDuration: Duration(milliseconds: 500),
        decelerationCurve: Curves.easeOut,
      ),
    );
  }

}
